package com.myapp.api.mapper;

import com.myapp.api.entity.Admin;
import org.apache.ibatis.jdbc.SQL;

public class AdminSqlProvider {

    public String insertSelective(Admin record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("admin");
        
        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getAccount() != null) {
            sql.VALUES("Account", "#{account,jdbcType=VARCHAR}");
        }
        
        if (record.getUsername() != null) {
            sql.VALUES("Username", "#{username,jdbcType=VARCHAR}");
        }
        
        if (record.getPwd() != null) {
            sql.VALUES("Pwd", "#{pwd,jdbcType=VARCHAR}");
        }
        
        if (record.getLogintime() != null) {
            sql.VALUES("LoginTime", "#{logintime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getLoginip() != null) {
            sql.VALUES("LoginIP", "#{loginip,jdbcType=VARCHAR}");
        }
        
        if (record.getRole() != null) {
            sql.VALUES("Role", "#{role,jdbcType=VARCHAR}");
        }
        
        if (record.getCreatetime() != null) {
            sql.VALUES("CreateTime", "#{createtime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdatetime() != null) {
            sql.VALUES("UpdateTime", "#{updatetime,jdbcType=TIMESTAMP}");
        }

        if (record.getAuthtoken() != null) {
            sql.VALUES("AuthToken", "#{authtoken,jdbcType=LONGVARCHAR}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(Admin record) {
        SQL sql = new SQL();
        sql.UPDATE("admin");
        
        if (record.getAccount() != null) {
            sql.SET("Account = #{account,jdbcType=VARCHAR}");
        }
        
        if (record.getUsername() != null) {
            sql.SET("Username = #{username,jdbcType=VARCHAR}");
        }
        
        if (record.getPwd() != null) {
            sql.SET("Pwd = #{pwd,jdbcType=VARCHAR}");
        }
        
        if (record.getLogintime() != null) {
            sql.SET("LoginTime = #{logintime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getLoginip() != null) {
            sql.SET("LoginIP = #{loginip,jdbcType=VARCHAR}");
        }
        
        if (record.getRole() != null) {
            sql.SET("Role = #{role,jdbcType=VARCHAR}");
        }
        
        if (record.getCreatetime() != null) {
            sql.SET("CreateTime = #{createtime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdatetime() != null) {
            sql.SET("UpdateTime = #{updatetime,jdbcType=TIMESTAMP}");
        }

        if (record.getAuthtoken() != null) {
            sql.SET("AuthToken = #{authtoken,jdbcType=LONGVARCHAR}");
        }
        
        sql.WHERE("id = #{id,jdbcType=INTEGER}");
        
        return sql.toString();
    }
}